package test.factory;

import test.Compute;
import test.impl.AddImpl;
import test.impl.ExceptImpl;
import test.impl.MultiplyImpl;
import test.impl.SubtractImpl;

public class ComputeFactory {
    /**
     * 工厂
     */
    public static Compute getCompute(String operation){
        switch (operation){
            case "+":
                return new AddImpl();
            case "-":
                return new SubtractImpl();
            case "*":
                return new MultiplyImpl();
            case "/":
                return new ExceptImpl();
            default:
                throw new RuntimeException("无效的运算符："+operation);
        }
    }
}
